import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:偶数前奇数后
 * User: 小梅就是酱子
 * Date: 2022-02-04
 * Time: 16:24
 */
public class 数组数字排列 {
    public static void main(String[] args) {
        int[] array={1,2,5,7,6,9,4,8};
        line(array);
        System.out.println(Arrays.toString(array));
    }
    public static void line(int[] array){
        int left=0;
        int right= array.length-1;
        while(left<right){
            while(left<right && array[left]%2==0){
                left++;
            }
            while(left<right && array[right]%2!=0){
                right--;
            }
            int tmp=array[left];
            array[left]=array[right];
            array[right]=tmp;
        }
    }
}
